﻿<!DOCTYPE html>
<html>
	<head>
		<title>编辑文件</title>
    $css()
    <link rel="stylesheet" href="/framework/assets/coder/cdr.css">
    <style type="text/css">
      body{margin:0;font-family:Arial;font-size:14px;}
      .file .txt{color:Black;}
      .CodeMirror{line-height:1.2};
    </style>
	</head>
<body>
<div class="tabarea">
  <form action="" method="post" id="form1">
    <div class="top" style="font-size:12px"><span class="tab" style="margin-left:25px">源代码</span>
    <a href="javascript:process('save')" class="btn">保存</a>&nbsp;&nbsp;${bakinfo}
    &nbsp;<!--<span class="txt">【当前修改文件】:&nbsp;&nbsp;</span>/${file}--></div>

    <input type="hidden" id="action" field="action" value="save" />
    <input type="hidden" id="path" field="path" value="${path}" />
    <textarea field="content" class="contentarea code" id="ctarea">${content}</textarea>
    <!--
    <div class="bottom"></div>-->
  </form>
</div>
$js()
<script type="text/javascript">
    var editor = document.getElementById('ctarea');
    var height = (document.documentElement.clientHeight - 31);
    editor.style.height = height + "px";
    editor.style.width = (document.documentElement.clientWidth - 14 - 2) + "px";
</script>
  <script src="/framework/assets/coder/cdr.js"></script>
  <script src="${dependJs}"></script>
  <script type="text/javascript">
      /*
      var mode='html';
      var ext=cms.request('path').replace(/[^.]+.([a-z]+)$/,'$1');
      switch (ext.toLowerCase()) {
          case 'css': mode = 'css';
              cms.ldScript('/framework/assets/coder/mode/css.js');
              break;
          case 'conf':
          case 'config':
          case 'xml':
              mode = 'xml'; break;
      }*/

      var coder = cms.coder(editor.id, { mode: '${mode}', height: height });
 
    function process(action) {
        document.getElementById('action').value = action;
        if (coder) {
            editor.value = coder.getValue();
        }

      //showLoading('操作处理中...');
      cms.xhr.post(location.href, cms.json.toObject('form1'), function (result) {
        if (result.indexOf('成功') == -1) {
          tip(false, result);
        } else {
          tip(true, result);
        }
      });
    }

    function tip(result, msg) {
        parent.parent.M.alert(msg);
    }

    cms.event.add(document, 'keydown', function (event) {
        var e = window.event || event;
        //CTRL+S保存
        if (e.ctrlKey && e.keyCode == 83) {
            process('save');
            return cms.event.preventDefault(e);
        }
    });

  </script>
</body>
</html>